FROM php:7.4-fpm

# 设置时区为上海
RUN rm -rf /etc/localtime && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -yqq && \
    apt-get install -y --assume-yes  apt-utils openssl libssl-dev && \
    pecl channel-update pecl.php.net && \
    apt-get install -y git && \
    curl -sS https://getcomposer.org/installer | php && \
    mv composer.phar /usr/bin/composer && \
    composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# Install the zip mysqli pdo_mysql extension
RUN apt-get install libzip-dev zip unzip -y

#   对于PHP< 7.3
#   docker-php-ext-configure zip --with-libzip && \
RUN docker-php-ext-install zip mysqli pdo_mysql

# Install gd iconv extension
RUN apt-get update && apt-get install -y \
      libfreetype6-dev \
      libjpeg62-turbo-dev \
      libpng-dev \
    && docker-php-ext-install -j$(nproc) iconv \
    && docker-php-ext-configure gd  --with-jpeg=/usr/include/ --with-freetype=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

# Install redis extension
RUN pecl install redis \
    &&  rm -rf /tmp/pear \
    &&  docker-php-ext-enable redis

# Install imagick
RUN apt-get install -y libmagickwand-dev imagemagick && \
    pecl install imagick && \
    docker-php-ext-enable imagick

# Install pcntl
RUN docker-php-ext-install pcntl

# Install crypt/math extension
RUN docker-php-ext-install bcmath

# Install opcache
RUN docker-php-ext-install opcache

RUN docker-php-ext-install fileinfo
RUN docker-php-ext-install exif

# Install swoole
#RUN pecl install swoole && docker-php-ext-enable swoole

# Install supervisor
#RUN apt-get update &&\
#    apt-get install -y supervisor &&\
#    touch /var/run/supervisor.sock &&\
#    chmod 777 /var/run/supervisor.sock &&\
#    unlink /var/run/supervisor.sock

# Install Node
# RUN apt-get update &&\
#    apt-get install -y --no-install-recommends gnupg &&\
#    curl -sL https://deb.nodesource.com/setup_10.x | bash - &&\
#    apt-get update &&\
#    apt-get install -y --no-install-recommends nodejs &&\
#    npm config set registry https://registry.npm.taobao.org --global &&\
#    npm install --global gulp-cli

# Clean up
RUN apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    rm /var/log/lastlog /var/log/faillog

CMD ["php-fpm"]

EXPOSE 9000

